package com.ce.pms.common.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

/**
 * Filter class
 *
 * @web.filter name="SetResponseCache" display-name="Name for SetResponseCache"
 *             description="Description for SetResponseCache"
 * @web.filter-mapping url-pattern="/SetResponseCache"
 * @web.filter-init-param name="A parameter" value="A value"
 */
public class ResponseCacheFilter implements Filter {

	public void destroy() {

	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		HttpServletResponse temp = (HttpServletResponse) response;
		temp.setHeader("Cache-Control", "no-cache"); // Forces caches to
														// obtain a new copy of
														// the page from the
														// origin server
		temp.setHeader("Cache-Control", "no-store"); // Directs caches not to
														// store the page under
														// any circumstance
		temp.setDateHeader("Expires", 0); // Causes the proxy cache to see the
											// page as "stale"
		temp.setHeader("Pragma", "no-cache"); // HTTP 1.0 backward
												// compatibility
		filterChain.doFilter(request, response);
	}

	public void init(FilterConfig arg0) throws ServletException {

	}

}
